package com.u17;

/**
 * @author u17
 * https://leetcode-cn.com/problems/remove-duplicates-from-sorted-list/
 */
public class Solution {

    public ListNode deleteDuplicates(ListNode head) {

        ListNode result = head;

        while (result != null && result.next !=null) {
            if (result.val != result.next.val) {
                result = result.next;
            } else {
                result.next = result.next.next;
            }
        }
        return head;
    }
}

class ListNode {
    int val;
    ListNode next;

    ListNode() {
    }

    ListNode(int val) {
        this.val = val;
    }

    ListNode(int val, ListNode next) {
        this.val = val;
        this.next = next;
    }
}
